#include<bits/stdc++.h>
#define Maxn 1000005 
using namespace std;
multiset<pair<int,int> > st;
multiset<pair<int,int> > p;
struct node {
    char a;
    int l,r;
} e[Maxn];
#define lson x<<1,l,mid 
#define rson x<<1|1,mid+1,r 
int sgt[Maxn<<2],lazy[Maxn<<2];
void build(int x,int l,int r) {
    lazy[x] = 0;
    if(l == r)return sgt[x] = 0,void();
    int mid = (l+r)>>1; build(lson),build(rson);
}
void merge(int x,int l,int r,int L,int R,int u) {
    if(L<=l&&r<=R)return lazy[x] += u,sgt[x] += (r-l+1)*u,void();
    int mid = (l+r)>>1;
    sgt[x<<1] += lazy[x]*(l-mid+1);
    sgt[x<<1|1] += lazy[x]*(r-mid);
    lazy[x<<1] += lazy[x];
    lazy[x<<1|1] += lazy[x];
    lazy[x] = 0;
    if(L <= mid)merge(lson,L,R,u);
    if(mid < R)merge(rson,L,R,u);
    sgt[x] = sgt[x<<1]+sgt[x<<1|1];
}
int query(int x,int l,int r,int L,int R) {
    if(L<=l&&r<=R)return sgt[x];
    int mid = (l+r)>>1;
    sgt[x<<1] += lazy[x]*(l-mid+1);
    sgt[x<<1|1] += lazy[x]*(r-mid);
    lazy[x<<1] += lazy[x];
    lazy[x<<1|1] += lazy[x];
    lazy[x] = 0;
    int ans = 0;
    if(L <= mid)ans += query(lson,L,R);
    if(mid < R)ans += query(rson,L,R);
    sgt[x] = sgt[x<<1]+sgt[x<<1|1];
    return ans;
}
#define lt 1,1,Maxn-1 
map<pair<int,int>,int> mp;
vector<int> Q[Maxn];
int vis[Maxn],res[Maxn];
int main()
{
    freopen("stone.in","r",stdin);
    freopen("stone.out","w",stdout);
    int q,flag = 0;
    cin>>q;
    for(int i=1;i<=q;i++) {
        cin>>e[i].a>>e[i].l>>e[i].r;
        if(!flag&&e[i].a == 'A') {
            if(query(lt,e[i].l,e[i].r))flag = 1;
            merge(lt,e[i].l,e[i].r,1);
        }
    }
    if(!flag) {
        for(int i=1;i<=q;i++) {
            if(e[i].a == 'A') {
                if(p.empty()) {
                    p.insert(make_pair(e[i].l,i));
                    st.insert({e[i].r-e[i].l,e[i].r-e[i].l});
                    cout<<(*st.begin()).second<<"\n";
                    continue;
                }
                auto u = p.lower_bound(make_pair(e[i].l,0));
                if(u == p.end()) {
                    int rc = (*(-- u)).second;
                    st.insert({0,max(e[rc].r,e[i].r)-min(e[rc].l,e[i].l)});
                    p.insert(make_pair(e[i].l,i));
                    st.insert({e[i].r-e[i].l,e[i].r-e[i].l});
                    cout<<(*st.begin()).second<<"\n";
                    continue;
                }
                int lc = (*u).second,rc = (*(-- u)).second;
                st.erase(st.lower_bound({0,max(e[lc].r,e[rc].r)-min(e[lc].l,e[rc].l)}));
                st.insert({0,max(e[lc].r,e[i].r)-min(e[lc].l,e[i].l)});
                st.insert({0,max(e[rc].r,e[i].r)-min(e[rc].l,e[i].l)});
                p.insert(make_pair(e[i].l,i));
                st.insert({e[i].r-e[i].l,e[i].r-e[i].l});
            } else {
                auto u = p.lower_bound(make_pair(e[i].l,0));
                if(u == p.begin()) {
                    int rc = (*(++u)).second;
                    st.erase(st.lower_bound({0,max(e[rc].r,e[i].r)-min(e[rc].l,e[i].l)}));
                    p.erase(make_pair(e[i].l,e[i].r));
                    st.erase(st.lower_bound({e[i].r-e[i].l,e[i].r-e[i].l}));
                    cout<<(*st.begin()).second<<"\n";
                    continue;
                } u ++;
                if(u == p.end()) {
                    u --;
                    int lc = (*(--u)).second;
                    st.erase(st.lower_bound({0,max(e[lc].r,e[i].r)-min(e[lc].l,e[i].l)}));
                    p.erase(make_pair(e[i].l,e[i].r));
                    st.erase(st.lower_bound({e[i].r-e[i].l,e[i].r-e[i].l}));
                    cout<<(*st.begin()).second<<"\n";
                    continue;
                } u --;
                int lc = (*(--u)).second;
                int x = (*(++u)).second;
                int rc = (*(++u)).second;
                st.insert({0,max(e[lc].r,e[rc].r)-min(e[lc].l,e[rc].l)});
                st.erase(st.lower_bound({0,max(e[lc].r,e[i].r)-min(e[lc].l,e[i].l)}));
                st.erase(st.lower_bound({0,max(e[rc].r,e[i].r)-min(e[rc].l,e[i].l)}));
                p.erase(make_pair(e[i].l,e[i].r));
                st.erase(st.lower_bound({e[i].r-e[i].l,e[i].r-e[i].l}));
            } cout<<(*st.begin()).second<<"\n";
        }
        return 0;
    } int ppp = 0,Time = 0;
    for(int i=1;i<=q;i++) {
        if(e[i].a == 'A') {
            if(!mp[make_pair(e[i].l,e[i].r)])
                mp[make_pair(e[i].l,e[i].r)] = ++ppp;
            Q[mp[make_pair(e[i].l,e[i].r)]].push_back(++Time);
            res[Time] = i;
        } else {
            vis[Q[mp[make_pair(e[i].l,e[i].r)]].back()] = 1;
            Q[mp[make_pair(e[i].l,e[i].r)]].pop_back();
        } int ans = INT_MAX,maxn = INT_MAX;
        for(int j=1;j<=Time;j++) {
            if(!vis[j]) {
                if(e[res[j]].r-e[res[j]].l < maxn)maxn = e[res[j]].r-e[res[j]].l,ans = INT_MAX;
                if(e[res[j]].r-e[res[j]].l == maxn)ans = min(ans,e[res[j]].r-e[res[j]].l);
                for(int k=j+1;k<=Time;k++) {
                    if(!vis[k]) {
                        if(max(0,min(e[res[j]].r,e[res[k]].r)-max(e[res[j]].l,e[res[k]].l)) < maxn)
                            maxn = max(0,min(e[res[j]].r,e[res[k]].r)-max(e[res[j]].l,e[res[k]].l)),ans = INT_MAX;
                        if(max(0,min(e[res[j]].r,e[res[k]].r)-max(e[res[j]].l,e[res[k]].l)) == maxn)
                            ans = min(ans,max(e[res[j]].r,e[res[k]].r)-min(e[res[j]].l,e[res[k]].l));
                    }
                }
            }
        } cout<<ans<<"\n";
    }
    return 0;
}
/*
5
A 1 5
A 2 7
A 4 6
A 6 8
R 4 6

2
A 1 3
A 4 7
*/